In [1]:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import mpl_toolkits as mplot3d
import scipy as sp
pd.set_option("display.max_columns", None)
from tqdm import tqdm
tqdm.pandas()
In [2]:
def lighten_color(color, amount=0.5):
"""
Lightens the given color by multiplying (1-luminosity) by the given amount.
Input can be matplotlib color string, hex string, or RGB tuple.
Examples:
>> lighten_color('g', 0.3)
>> lighten_color('#F034A3', 0.6)
>> lighten_color((.3,.55,.1), 0.5)
"""
import matplotlib.colors as mc
import colorsys
try:
c = mc.cnames[color]
except:
c = color
c = colorsys.rgb_to_hls(*mc.to_rgb(c))
return colorsys.hls_to_rgb(c[0], 1 - amount * (1 - c[1]), c[2])
DATA CLEANING AND WRANGLING¶
Typeform Data¶
In [3]:
d0 = pd.read_csv('India_riskliteracy_dataset_above median_2024_new.csv').rename({"#":"ResponseId"}, axis = 1)
d0
Out[3]:
| ResponseId | Unnamed: 1 | #.1 | Please indicate your Gender. | Please mark your age (in years) | What is currently your highest Education? | Please state your current occupation. | How do you describe your willingness to take financial risk in general? | Given the number of years that you have held various investments and the amount of investing you might have done, what degree of investment experience in the stock market do you have? | If an expert tries to worry or scare me, i.e. a financial advisor about my financial situation, I choose another expert. | I only buy a financial product I understand. | I trust doctors. | When I want to buy a bigger item like a refrigerator or an expensive item of clothing, I wait a month to see whether I still want it and only buy it then. | I always keep in mind that everything I do on the web could be used to my disadvantage. | In my household, we/I spend: | In my household, we/I | _Distribution 1_\n\nHow risky do you perceive the investment to be? | _Distribution 2_\n\nHow risky do you perceive the investment to be? | _Distribution 3_\n\nHow risky do you perceive the investment to be? | _Distribution 4_\n\nHow risky do you perceive the investment to be? | _Distribution 5_\n\nHow risky do you perceive the investment to be? | Distribution 6\n\nHow risky do you perceive the investment to be? | Distribution 7\n\nHow risky do you perceive the investment to be? | Distribution 8\n\nHow risky do you perceive the investment to be? | *Mumbai * A = 9 out of 10000 *OR * B = 1 out of 1000 | *Bengaluru * A = 0.7% *OR * B = 0.099% | *Kolkata * A = 0.61% *OR * B = 6 out of 10000 | HIV test | Fingerprint | DNA test | Cancer screening test | Professional horoscope | A study estimates that eating 100g chocolate everyday increases the risk of obesity by 20%. Which of the following statements is true? | There is an official prediction that the national stock market will grow 2% annually over the next 5 years. This means that… | Imagine you are told that the price of the stock Soya Ruchi increases from INR 60 to INR 120 after the company merger. What does this mean? | It is predicted that Indigo Bank has 30% chance of default next year. Which of the following alternatives is the most appropriate interpretation of the statement? | The probability that the economy will go into a recession this year is 30%. If the economy goes into recession, the probability that the stock market will decrease is 80%. If the economy does not go into a recession, the probability that the stock market will decrease is 23%. What is the probability that the economy goes into recession given that the stock market decreased? | A new policy intervention increases the number of people who are employed by 20%. This statistic implies that the intervention increases the number of people who are employed from: | Imagine you are told that a new medication increases the number of people who recover from a disease from 2 out of 1,000 to 4 out of 1,000. This implies: | Imagine that we flip a fair coin 1,000 times. What is your best guess about how many times the coin will come up heads in 1,000 flips? \n\n\_\_\_\_\_\_ times out of 1,000. | In the Bingo Lottery, the chance of winning a $10 prize is 1%. What is your best guess about how many people will win a $10 prize if 1,000 people each buy a single ticket for Bingo Lottery?\n\n\_\_\_\_\_\_ person(s) out of 1,000. | In a sweepstakes, the chance of winning a car is 1 in 1,000. What percentage of tickets for the sweepstakes wins a car?\n\n\_\_\_\_\_ % of tickets | About 10 out of 1,000 children develop Down syndrome. In a Down syndrome test, 9 out of these 10 children with Down syndrome tested positive. Out of the 990 children without Down syndrome 50 nevertheless tested positive. Among those women with a positive test result concerning their child how many actually have a child with Down syndrome? [Select one response only] | Approximately what percentage (%) of people who die from cancer die from colon cancer, breast cancer, and prostate cancer taken together? | The following figure shows the number of men and women among a group of smartphone users. The total number of circles is 100. \n\nHow many more men than women are there among the 100 people using a smartphone? | In a magazine you see two advertisements, one on page 5 and another on page 12. Each is for a different drug for treating heart disease, and each includes a graph showing the effectiveness of the drug compared to a placebo (sugar pill).\n\nCompared to the placebo, which treatment leads to a larger decrease in the percentage of patients who die? | Please indicate your approximate annual personal income from all sources for last year | Please provide a rough guess (in Indian Rupees) of the worth of your household's assets. Please do not forget to correct it for your debts, such as a mortgage or any loans you might have. | uid | Response Type | Start Date (UTC) | Stage Date (UTC) | Submit Date (UTC) | Network ID | LTA | q8_2_1 | q8_2_2 | q8_2_3 | q8_2_4 | q8_2_5 | q8_3 | q8_4 | q8_5berlin_1 | q8_5london_1 | q8_5paris_1 | q8_6 | q8_7 | q9_1_1 | q9_2_1 | q9_3 | q10_1_1 | q10_2_1 | q10_3_1 | q10_4 | certainty1 | certainty2 | certainty3 | certainty4 | certainty5 | uncertainty1 | uncertainty2 | numeracy1 | numeracy2 | numeracy3 | numeracy4 | numeracy5 | graph1 | graph2 | graph3 | riskcalculation1 | riskcalculation2 | riskcalculation3 | riskcalculation4 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 00dn8csjzlekx6gzhrcv00dn8csj32tz | 547 | 00dn8csjzlekx6gzhrcv00dn8csj32tz | Male | 25 - 35 | Under Graduate | Investment Professional, i.e. stock broker/tra... | 7 | 10 | Completely | Just about | Completely | Completely | Just about | all or more than the household income, even th... | have an emergency fund, and spend as it feels ... | 7 | 7 | 7 | 6 | 6 | 6 | 6 | 7 | A | B | A | Yes | Yes | Yes | Yes | Yes | The lower the quality of the study, the more l... | the growth rate will be 0.4% on average each year | the stock price increased by 50% | 30% of the banks customers will default next year | 30% | it is not possible to determine which of the a... | The medication increases recovery by 50% | 30 | 20 | 30 | 9 out of 10 | 40 | 60 | They are equal | 5,00,000 - 15,00,000 | 50000 | MX9oX1724844773oYI | completed | 2024-08-28 11:35:35 | NaN | 2024-08-28 12:02:05 | f30fdd629e | 18.402778 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 2 | 4 | 40 | 60 | 3 | 30 | 20 | 30 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 00ujdxbfoya0donu8r00ujcjdkojc99x | 428 | 00ujdxbfoya0donu8r00ujcjdkojc99x | Female | 25 - 35 | Under Graduate | Employee/Consultant in Other than the Finance ... | 7 | 8 | Completely | Completely | Completely | Moderately | Moderately | less than half of the household income and sav... | write down budget and spending, and have an em... | 2 | 1 | 1 | 1 | 0 | 2 | 0 | 0 | B | B | A | Yes | Yes | Yes | Yes | No | The higher the quality of the study, the more ... | the growth rate over five years will be betwee... | the stock price increased by 50% | The bank will default on 30% of repayments in ... | 50% | 100 in 10,000 people prior to the intervention... | The medication increases recovery by 50% | 500 | 100 | 1 | 59 out of 1000 | 50 | 10 | They are equal | < 5,00,000 | 1500000 | MXic21725178744djB | completed | 2024-09-01 08:23:04 | NaN | 2024-09-01 09:24:44 | 1c1d51349c | 42.824074 | 1 | 1 | 1 | 1 | 2 | 2 | 3 | 2 | 2 | 1 | 2 | 2 | 50 | 10 | 3 | 500 | 100 | 1 | 3 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 2 | 01ro2iftnum5v4cn01r03c75aa24emhq | 528 | 01ro2iftnum5v4cn01r03c75aa24emhq | Female | 18 - 25 | Under Graduate | Student | 5 | 8 | Just about | Completely | Completely | Completely | Just about | more than half of the household income and sav... | write down budget and spending, and have an em... | 6 | 6 | 2 | 6 | 6 | 6 | 2 | 4 | A | B | B | Yes | Yes | No | Yes | Yes | The lower the quality of the study, the more l... | the growth rate over five years will be exactl... | an answer is not possible based on the informa... | Banks similar to Indigo will default 30% of th... | 50% | 70 in 100 people prior to the intervention to ... | The medication increases recovery by 100% | 46 | 100 | 99 | 59 out of 1000 | 79 | 40 | Hertinol | 5,00,000 - 15,00,000 | 500000 | MX7wI1724844822zNm | completed | 2024-08-28 11:36:50 | NaN | 2024-08-28 11:51:07 | 81a8a6836a | 9.918981 | 1 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 2 | 2 | 1 | 3 | 79 | 40 | 2 | 46 | 100 | 99 | 3 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 3 | 022xoawhrghfhv4a1g022xmz7hb0m41f | 442 | 022xoawhrghfhv4a1g022xmz7hb0m41f | Female | 46 - 55 | Under Graduate | Entrepreneur or Own Business | 5 | 4 | Somewhat | Somewhat | Moderately | Just about | Somewhat | all or more than the household income, even th... | spend as it feel right, and do not have an eme... | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | B | A | B | Yes | Yes | Yes | No | No | The lower the quality of the study, the more l... | the growth rate will be 0.4% on average each year | the stock price increased by 60% | 30% of the banks customers will default next year | 80% | 5 in 100 people prior to the intervention to 6... | The medication increases recovery by 2% | 500 | 1 | 1 | 59 out of 1000 | 17 | 65 | They are equal | < 5,00,000 | 15000000 | MXFDH1725178659xRn | completed | 2024-09-01 08:21:14 | NaN | 2024-09-01 08:33:49 | fbd8962401 | 8.738426 | 1 | 1 | 1 | 2 | 2 | 1 | 1 | 2 | 1 | 2 | 3 | 1 | 17 | 65 | 3 | 500 | 1 | 1 | 3 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 4 | 02pxtdbyibecqqfvwlw02pxwfbane9zd | 558 | 02pxtdbyibecqqfvwlw02pxwfbane9zd | Female | 46 - 55 | Post Graduate | Employee/Consultant in Other than the Finance ... | 6 | 10 | Not at all | Completely | Completely | Completely | Moderately | all or more than the household income, even th... | have an emergency fund, and spend as it feels ... | 5 | 5 | 6 | 5 | 7 | 5 | 0 | 5 | B | A | A | Yes | Yes | Yes | No | Yes | The higher the quality of the study, the more ... | it is not possible to predict the growth rate ... | an answer is not possible based on the informa... | 30% of the banks customers will default next year | 30% | 5 in 100 people prior to the intervention to 6... | None of the above is implied. | 1000 | 1 | 100 | 9 out of 10 | 20 | 20 | Can’t say | 5,00,000 - 15,00,000 | 3000000 | MXIpM1724844742xet | completed | 2024-08-28 11:35:05 | NaN | 2024-08-28 11:48:47 | e8b668d11b | 9.513889 | 1 | 1 | 1 | 2 | 1 | 2 | 4 | 2 | 1 | 1 | 4 | 1 | 20 | 20 | 4 | 1000 | 1 | 100 | 2 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | zeoufbqlngfunzzeoymhtj2sp5cw6lur | 396 | zeoufbqlngfunzzeoymhtj2sp5cw6lur | Male | 25 - 35 | Post Graduate | Investment Professional, i.e. stock broker/tra... | 3 | 8 | Not at all | Somewhat | Somewhat | Moderately | Somewhat | less than half of the household income and sav... | spend as it feel right, and do not have an eme... | 3 | 4 | 4 | 3 | 6 | 6 | 3 | 4 | B | A | A | No | Yes | No | No | No | The higher the quality of the study, the more ... | the growth rate over five years will be exactl... | the stock price increased by 100% | Banks similar to Indigo will default 30% of th... | 50% | 70 in 100 people prior to the intervention to ... | The medication increases recovery by 100% | 500 | 100 | 1 | 59 out of 1000 | 50 | 40 | Crosicol | < 5,00,000 | 50000 | MXFoD1725258821KAh | completed | 2024-09-02 06:36:01 | NaN | 2024-09-02 06:46:38 | c31fa70c8d | 7.372685 | 2 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 1 | 1 | 1 | 3 | 50 | 40 | 1 | 500 | 100 | 1 | 3 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 639 | zfemo30rg0ekva18x1kjwzfemo2wpg2p | 185 | zfemo30rg0ekva18x1kjwzfemo2wpg2p | Male | 36 - 45 | Ph.D. or higher | Employee/Consultant in Other than the Finance ... | 6 | 8 | Not at all | Moderately | Just about | Not at all | Not at all | less than half of the household income and sav... | have an emergency fund, and spend as it feels ... | 3 | 1 | 4 | 2 | 0 | 5 | 0 | 2 | B | A | A | No | Yes | Yes | No | No | Irrespective of the quality of the study, futu... | the growth rate over five years will be betwee... | the stock price increased by 100% | 30% of central bankers think that Indigo Bank ... | 30% | 100 in 10,000 people prior to the intervention... | The medication increases recovery by 100% | 500 | 10 | 1 | 59 out of 1000 | 25 | 20 | Can’t say | 15,00,001 - 25,00,000 | 8500000 | MXUxt1725260651heG | completed | 2024-09-02 07:08:18 | NaN | 2024-09-02 07:23:09 | fbb956cffc | 10.312500 | 2 | 1 | 1 | 2 | 2 | 4 | 3 | 2 | 1 | 1 | 1 | 2 | 25 | 20 | 4 | 500 | 10 | 1 | 3 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 |
| 640 | znqvw4t38br3072znqvwvjsgb6wvj7nt | 305 | znqvw4t38br3072znqvwvjsgb6wvj7nt | Female | 36 - 45 | Post Graduate | Entrepreneur or Own Business | 5 | 5 | Somewhat | Completely | Just about | Moderately | Somewhat | less than half of the household income and sav... | spend as it feel right, and do not have an eme... | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | B | B | B | Yes | Yes | Yes | No | No | Irrespective of the quality of the study, futu... | it is not possible to predict the growth rate ... | the stock price increased by 50% | 30% of the banks customers will default next year | 80% | it is not possible to determine which of the a... | The medication increases recovery by 2% | 500 | 10 | 1 | 9 out of 59 | 25 | 20 | Hertinol | 5,00,000 - 15,00,000 | 2000000 | MXd921725259652XDJ | completed | 2024-09-02 06:49:56 | NaN | 2024-09-02 07:17:20 | 1964f49e1c | 19.027778 | 1 | 1 | 1 | 2 | 2 | 3 | 4 | 2 | 2 | 2 | 3 | 4 | 25 | 20 | 2 | 500 | 10 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
| 641 | zstpq23h1x3ilab8s8vsrbkw8t4zstpq | 306 | zstpq23h1x3ilab8s8vsrbkw8t4zstpq | Male | 18 - 25 | Under Graduate | Entrepreneur or Own Business | 6 | 9 | Completely | Completely | Moderately | Completely | Moderately | all or more than our household income, because... | have an emergency fund, and spend as it feels ... | 6 | 3 | 7 | 1 | 2 | 7 | 7 | 3 | A | A | B | No | Yes | Yes | No | No | The higher the quality of the study, the more ... | the growth rate over five years will be betwee... | the stock price increased by 60% | Banks similar to Indigo will default 30% of th... | 80% | 5 in 100 people prior to the intervention to 6... | None of the above is implied. | 750 | 10 | 1 | 59 out of 1000 | 50 | 10 | They are equal | 5,00,000 - 15,00,000 | 60000000 | MXfmg1725259705Fkj | completed | 2024-09-02 06:49:52 | NaN | 2024-09-02 07:01:04 | 03aa77ec48 | 7.777778 | 2 | 1 | 1 | 2 | 2 | 2 | 3 | 1 | 1 | 2 | 4 | 1 | 50 | 10 | 3 | 750 | 10 | 1 | 3 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 642 | ztfdlcbiyo1xco3ztfdl4ozqpte2q3m9 | 95 | ztfdlcbiyo1xco3ztfdl4ozqpte2q3m9 | Male | 25 - 35 | Post Graduate | Entrepreneur or Own Business | 6 | 7 | Somewhat | Just about | Completely | Moderately | Somewhat | more than half of the household income and sav... | spend as it feel right, and do not have an eme... | 6 | 0 | 2 | 5 | 3 | 7 | 0 | 4 | B | A | A | No | Yes | Yes | Yes | Yes | The higher the quality of the study, the more ... | it is not possible to predict the growth rate ... | the stock price increased by 100% | 30% of central bankers think that Indigo Bank ... | 80% | 5 in 100 people prior to the intervention to 6... | The medication increases recovery by 2% | 500 | 10 | 1 | 59 out of 1000 | 25 | 60 | Can’t say | 15,00,001 - 25,00,000 | 5000000 | MXjp51725955476hMt | completed | 2024-09-10 08:06:34 | NaN | 2024-09-10 08:16:35 | f68294192e | 6.956019 | 2 | 1 | 1 | 1 | 1 | 2 | 4 | 2 | 1 | 1 | 3 | 1 | 25 | 60 | 4 | 500 | 10 | 1 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
643 rows × 93 columns
Demographics¶
In [4]:
# Age groups/rec = [2,3,4]
# Age group 2 = 18 to 35 y/o
# Age group 3 = 36 to 55 y/o
# Age group 4 = 56 to 75 y/o (75 y/o, i.e, within the scope of the data we have, it can mean 60 and above also)
d0["age_rec"] = np.where( d0["Please mark your age (in years)"] == "18 - 25" , 2,
np.where(d0["Please mark your age (in years)"] == "25 - 35", 2,
np.where( d0["Please mark your age (in years)"] == "36 - 45", 3,
np.where( d0["Please mark your age (in years)"] == "46 - 55", 3,
np.where( d0["Please mark your age (in years)"] == "56 - 65", 4,
np.where( d0["Please mark your age (in years)"] == "Above 65", 4, 0
)
)
)
)
)
)
d0["age"] = np.where( d0["Please mark your age (in years)"] == "18 - 25" , (18 + 25) / 2,
np.where(d0["Please mark your age (in years)"] == "25 - 35", (26 + 35) / 2,
np.where( d0["Please mark your age (in years)"] == "36 - 45", (36 + 45) / 2,
np.where( d0["Please mark your age (in years)"] == "46 - 55", (46 + 55) / 2,
np.where( d0["Please mark your age (in years)"] == "56 - 65", (56 + 65) / 2,
np.where( d0["Please mark your age (in years)"] == "Above 65", (66 + 75) / 2, 0
)
)
)
)
)
)
# Secondary upto 10 – ISCED 3
# Senior Secondary upto 12 - ISCED 3
# Diploma and voca – ISCED 2
# UG – ISCED 2
# PG – ISCED 1
# PhD and higher – ISCED 1
d0["isced"] = np.where(d0["What is currently your highest Education?"] == "Post Graduate", 1,
np.where(d0["What is currently your highest Education?"] == "Under Graduate", 2,
np.where(d0["What is currently your highest Education?"] == "Ph.D. or higher", 1,
np.where(d0["What is currently your highest Education?"] == "Diploma or vocation training", 2,
np.where(d0["What is currently your highest Education?"] == "School degree (X or XII)", 3, 0
)
)
)
)
)
d0["income"] = np.where(d0["Please indicate your approximate annual personal income from all sources for last year"] == "< 5,00,000", 1,
np.where(d0["Please indicate your approximate annual personal income from all sources for last year"] == "5,00,000 - 15,00,000", 2,
np.where(d0["Please indicate your approximate annual personal income from all sources for last year"] == "15,00,001 - 25,00,000", 3,
np.where(d0["Please indicate your approximate annual personal income from all sources for last year"] == "25,00,001 - 35,00,000", 4,
np.where(d0["Please indicate your approximate annual personal income from all sources for last year"] == "35,00,001 - 45,00,000", 5,
np.where( d0["Please indicate your approximate annual personal income from all sources for last year"] == "> 45,00,000", 6,0
)
)
)
)
)
)
d0["wealth"] = d0["Please provide a rough guess (in Indian Rupees) of the worth of your household's assets. Please do not forget to correct it for your debts, such as a mortgage or any loans you might have."]
In [ ]:
In [ ]:
Scoring¶
In [5]:
d0["Certainty_3"] = d0["certainty1"] + d0["certainty2"] + d0["certainty3"]
d0["RiskComprehension_3"] = d0["riskcalculation1"] + d0["riskcalculation2"] + d0["riskcalculation4"]
d0["GraphLiteracy_3"] = d0["graph1"] + d0["graph2"] + d0["graph3"]
d0["Numeracy_3"] = d0["numeracy1"] + d0["numeracy2"] + d0["numeracy3"]
d0["Bayesianreasoning_1"] = d0["numeracy4"]
d0["TotalScore_13"] = d0["Certainty_3"] + d0["RiskComprehension_3"] + d0["GraphLiteracy_3"] + d0["Numeracy_3"] + d0["Bayesianreasoning_1"]
d0["Certainty_%"] = d0["Certainty_3"] / 3 * 100
d0["RiskComprehension_%"] = d0["RiskComprehension_3"] / 3 * 100
d0["GraphLiteracy_%"] = d0["GraphLiteracy_3"] / 3 * 100
d0["Numeracy_%"] = d0["Numeracy_3"] / 3 * 100
d0["Bayesianreasoning_%"] = d0["Bayesianreasoning_1"] / 1 * 100
d0["TotalScore_%"] = d0["TotalScore_13"] / 13 * 100
colReq = ["ResponseId", "age", "age_rec", "isced", "income", "wealth", "Certainty_3", "RiskComprehension_3", "GraphLiteracy_3",
"Numeracy_3", "Bayesianreasoning_1", "Certainty_%", "RiskComprehension_%", "GraphLiteracy_%", "Numeracy_%", "Bayesianreasoning_%",
"TotalScore_13", "TotalScore_%",]
df2 = d0[colReq].copy()
df2
Out[5]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 00dn8csjzlekx6gzhrcv00dn8csj32tz | 30.5 | 2 | 2 | 2 | 50000 | 0 | 0 | 1 | 1 | 0 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 0.0 | 2 | 15.384615 |
| 1 | 00ujdxbfoya0donu8r00ujcjdkojc99x | 30.5 | 2 | 2 | 1 | 1500000 | 0 | 1 | 1 | 2 | 0 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.0 | 4 | 30.769231 |
| 2 | 01ro2iftnum5v4cn01r03c75aa24emhq | 21.5 | 2 | 2 | 2 | 500000 | 1 | 0 | 0 | 0 | 1 | 33.333333 | 0.000000 | 0.000000 | 0.000000 | 100.0 | 2 | 15.384615 |
| 3 | 022xoawhrghfhv4a1g022xmz7hb0m41f | 50.5 | 3 | 2 | 1 | 15000000 | 0 | 1 | 1 | 2 | 0 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.0 | 4 | 30.769231 |
| 4 | 02pxtdbyibecqqfvwlw02pxwfbane9zd | 50.5 | 3 | 1 | 2 | 3000000 | 0 | 0 | 1 | 3 | 0 | 0.000000 | 0.000000 | 33.333333 | 100.000000 | 0.0 | 4 | 30.769231 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | zeoufbqlngfunzzeoymhtj2sp5cw6lur | 30.5 | 2 | 1 | 1 | 50000 | 2 | 1 | 0 | 3 | 1 | 66.666667 | 33.333333 | 0.000000 | 100.000000 | 100.0 | 7 | 53.846154 |
| 639 | zfemo30rg0ekva18x1kjwzfemo2wpg2p | 40.5 | 3 | 1 | 3 | 8500000 | 1 | 2 | 2 | 3 | 1 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 100.0 | 9 | 69.230769 |
| 640 | znqvw4t38br3072znqvwvjsgb6wvj7nt | 40.5 | 3 | 1 | 2 | 2000000 | 0 | 3 | 2 | 1 | 0 | 0.000000 | 100.000000 | 66.666667 | 33.333333 | 0.0 | 6 | 46.153846 |
| 641 | zstpq23h1x3ilab8s8vsrbkw8t4zstpq | 21.5 | 2 | 2 | 2 | 60000000 | 1 | 1 | 1 | 1 | 0 | 33.333333 | 33.333333 | 33.333333 | 33.333333 | 0.0 | 4 | 30.769231 |
| 642 | ztfdlcbiyo1xco3ztfdl4ozqpte2q3m9 | 30.5 | 2 | 1 | 3 | 5000000 | 1 | 2 | 1 | 3 | 0 | 33.333333 | 66.666667 | 33.333333 | 100.000000 | 0.0 | 7 | 53.846154 |
643 rows × 18 columns
In [ ]:
In [ ]:
GRAPHS¶
In [6]:
# The following graph represents frequency of each data point on "TotalScore_13" or the total score out of 19 questions across the sample.
df2['TotalScore_13'].plot(kind = 'hist', xticks = np.arange(0, 15, step=1), xlabel = 'TotalScore_13', title = 'Frequency of Scores' )
Out[6]:
<Axes: title={'center': 'Frequency of Scores'}, xlabel='TotalScore_13', ylabel='Frequency'>
In [7]:
# Absolute mean scores for each facet
(df2[['Certainty_3','RiskComprehension_3','GraphLiteracy_3','Numeracy_3','Bayesianreasoning_1','TotalScore_13']].mean(axis = 0)).plot(kind = 'bar', title = 'Absolute mean of scores for above data set')
Out[7]:
<Axes: title={'center': 'Absolute mean of scores for above data set'}>
In [8]:
# Normalised mean scores for each facet
df2[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%','TotalScore_%']].mean(axis = 0).plot(kind = 'bar', title = 'Normalised mean of scores for above data set')
Out[8]:
<Axes: title={'center': 'Normalised mean of scores for above data set'}>
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [9]:
# DF3 = Sorted by income
df3 = df2.sort_values(by = 'income')
df3 = df3.reset_index(drop = True)
df3.drop(df3[df3['income'] == 7].index, inplace = True)
df3
Out[9]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ingapx8z0r0iwgemwuiiingaf2dww17d | 21.5 | 2 | 2 | 1 | 500000 | 0 | 0 | 1 | 3 | 0 | 0.000000 | 0.000000 | 33.333333 | 100.000000 | 0.0 | 4 | 30.769231 |
| 1 | 75j5pullab0sviophrp0hc75j5pulim7 | 40.5 | 3 | 1 | 1 | 25000 | 0 | 2 | 2 | 3 | 0 | 0.000000 | 66.666667 | 66.666667 | 100.000000 | 0.0 | 7 | 53.846154 |
| 2 | 77fnlcmnn3dd87xjjuo77fnlcmed8um0 | 21.5 | 2 | 2 | 1 | 400000 | 1 | 3 | 1 | 2 | 1 | 33.333333 | 100.000000 | 33.333333 | 66.666667 | 100.0 | 8 | 61.538462 |
| 3 | s0p9cmpv4i57ggdrg5s0p9celrn67f5t | 30.5 | 2 | 2 | 1 | 10000 | 0 | 2 | 0 | 2 | 1 | 0.000000 | 66.666667 | 0.000000 | 66.666667 | 100.0 | 5 | 38.461538 |
| 4 | qt4btily2rqt6phgfaldqt4btixo2oe9 | 30.5 | 2 | 1 | 1 | 600000 | 0 | 0 | 2 | 1 | 0 | 0.000000 | 0.000000 | 66.666667 | 33.333333 | 0.0 | 3 | 23.076923 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | gs539g4qtok8tm7rmcjegs539g7ozj75 | 50.5 | 3 | 1 | 6 | 10000000 | 1 | 2 | 1 | 2 | 0 | 33.333333 | 66.666667 | 33.333333 | 66.666667 | 0.0 | 6 | 46.153846 |
| 639 | jajunac3e3j0oukoghbjajud9u72ogvy | 50.5 | 3 | 1 | 6 | 25000000 | 0 | 1 | 1 | 1 | 0 | 0.000000 | 33.333333 | 33.333333 | 33.333333 | 0.0 | 3 | 23.076923 |
| 640 | j6fzpylzfvgvsej6fzpyd0uzp0f1th8x | 30.5 | 2 | 1 | 6 | 100000000 | 0 | 1 | 3 | 1 | 0 | 0.000000 | 33.333333 | 100.000000 | 33.333333 | 0.0 | 5 | 38.461538 |
| 641 | f14uszmzhoujwobpkif14uszd4f33ehs | 50.5 | 3 | 1 | 6 | 500000 | 2 | 0 | 2 | 0 | 0 | 66.666667 | 0.000000 | 66.666667 | 0.000000 | 0.0 | 4 | 30.769231 |
| 642 | x292ml1l4xbxk1apxczo1x292ml1chrx | 30.5 | 2 | 1 | 6 | 10000000 | 1 | 1 | 2 | 1 | 0 | 33.333333 | 33.333333 | 66.666667 | 33.333333 | 0.0 | 5 | 38.461538 |
643 rows × 18 columns
In [10]:
# Absolute mean score for each facet (Sort by Income)
df3[['Certainty_3','RiskComprehension_3','GraphLiteracy_3','Numeracy_3','Bayesianreasoning_1','TotalScore_13']].mean(axis = 0).plot(kind = 'bar', title = 'Absolute mean score for each facet (Sort by Income)')
Out[10]:
<Axes: title={'center': 'Absolute mean score for each facet (Sort by Income)'}>
In [11]:
# Normalised mean score for each facet (Sort by Income)
(df3[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%','TotalScore_%']].mean(axis = 0)).plot(kind = 'bar', title = 'Normalised mean score for each facet (Sort by Income)')
Out[11]:
<Axes: title={'center': 'Normalised mean score for each facet (Sort by Income)'}>
In [12]:
# Normalised mean of each facet as a numerical (sorted by income)
df3.groupby('income')[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%','TotalScore_%']].mean()
Out[12]:
| Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_% | |
|---|---|---|---|---|---|---|
| income | ||||||
| 1 | 21.066667 | 35.733333 | 37.600000 | 60.000000 | 23.200000 | 37.415385 |
| 2 | 18.505338 | 41.992883 | 42.586002 | 57.532622 | 25.978648 | 39.063783 |
| 3 | 21.763085 | 41.046832 | 36.639118 | 59.228650 | 24.793388 | 38.525111 |
| 4 | 21.739130 | 38.405797 | 32.608696 | 56.521739 | 23.913043 | 36.287625 |
| 5 | 18.518519 | 35.185185 | 42.592593 | 49.074074 | 36.111111 | 36.324786 |
| 6 | 18.627451 | 41.176471 | 38.235294 | 50.980392 | 26.470588 | 36.425339 |
In [13]:
# Count of responses for each category (sorted by income)
df3.groupby('income')[['ResponseId']].count()
Out[13]:
| ResponseId | |
|---|---|
| income | |
| 1 | 125 |
| 2 | 281 |
| 3 | 121 |
| 4 | 46 |
| 5 | 36 |
| 6 | 34 |
In [14]:
# Absolute mean of Total Facet score line plot (sorted by income)
df3.groupby('income')[['TotalScore_13']].mean().plot( kind = 'line', title = 'Absolute mean of Total Facet score line plot (sorted by income)').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[14]:
<matplotlib.legend.Legend at 0x1f817aa8c90>
In [15]:
# Absolute mean of each Facet score line plot (sorted by income)
df3.groupby('income')[['Certainty_3','RiskComprehension_3','GraphLiteracy_3','Numeracy_3','Bayesianreasoning_1']].mean().plot( kind = 'line', title = 'Absolute Facet scores mean line plot').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[15]:
<matplotlib.legend.Legend at 0x1f817ad09d0>
In [16]:
# Normalised mean of each Facet score line plot (sorted by income)
df3.groupby('income')[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%', 'TotalScore_%']].mean().plot( kind = 'line', title = 'Normalised mean of each Facet score line plot (sorted by income)').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[16]:
<matplotlib.legend.Legend at 0x1f817621b90>
In [17]:
# Normalised mean of each Facet score stacked plot (sorted by income)
df3.groupby('income')[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%']].mean().plot( kind = 'bar', title = 'Normalised mean of each Facet score stacked plot (sorted by income)', stacked = True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[17]:
<matplotlib.legend.Legend at 0x1f8173a6710>
In [18]:
# Normalised mean of each Facet score hist plot (sorted by income)
df3.groupby('income')[['Certainty_%','RiskComprehension_%','GraphLiteracy_%','Numeracy_%','Bayesianreasoning_%','TotalScore_%']].mean().T.plot(kind = 'bar', title = 'Normalised mean scores for each facet for each wealth response category').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[18]:
<matplotlib.legend.Legend at 0x1f817af09d0>
In [19]:
# Trend line for Absolute Total Facet Score vs income
sns.regplot (data = df3, x = 'income', y = 'TotalScore_13')
Out[19]:
<Axes: xlabel='income', ylabel='TotalScore_13'>
In [20]:
# Trend line for Absolute Independent Facet Score vs income reponses
fig, ax = plt.subplots(figsize=(6, 6))
sns.regplot (data = df3, x = 'income', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax, label='Certainty_3')
sns.regplot (data = df3, x = 'income', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax, label='RiskComprehension_3')
sns.regplot (data = df3, x = 'income', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax, label='Numeracy_3')
sns.regplot (data = df3, x = 'income', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax, label='GraphLiteracy_3')
sns.regplot (data = df3, x = 'income', y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax, label='Bayesianreasoning_1' )
ax.set(ylabel='Scores', xlabel='income')
ax.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [21]:
# Violine Plot for TotalScore_13 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'TotalScore_13')
Out[21]:
<Axes: xlabel='income', ylabel='TotalScore_13'>
In [22]:
# Violine Plot for Certainty_3 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'Certainty_3')
Out[22]:
<Axes: xlabel='income', ylabel='Certainty_3'>
In [23]:
# Violine Plot for RiskComprehension_3 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'RiskComprehension_3')
Out[23]:
<Axes: xlabel='income', ylabel='RiskComprehension_3'>
In [24]:
# Violine Plot for GraphLiteracy_3 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'GraphLiteracy_3')
Out[24]:
<Axes: xlabel='income', ylabel='GraphLiteracy_3'>
In [25]:
# Violine Plot for Numeracy_3 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'Numeracy_3')
Out[25]:
<Axes: xlabel='income', ylabel='Numeracy_3'>
In [26]:
# Violine Plot for TotalScore_13 for each entry under income.
sns.violinplot( data = df3, x = 'income', y = 'Bayesianreasoning_1')
Out[26]:
<Axes: xlabel='income', ylabel='Bayesianreasoning_1'>
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [27]:
# Data Frame 2 or df2 is an aggregate data on facet total scores and over all total score, along with wealth and income data vs each response.
# This data set is also sorted by wealth with all responses 'NA' removed.
# We also assign quartiles ranking each response according to this sort.
df4 = df2.sort_values(by = 'wealth')
df4 = df4.reset_index(drop = True)
df4 = df4.dropna(axis = 0, subset = 'wealth')
df4.insert(loc = len(df4.columns), column = "Quartile Number", value = pd.qcut(df4["wealth"],q = 4, labels = False ) + 1, allow_duplicates = 'False')
df4
Out[27]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | Quartile Number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2rkur9ckjvsyz36zmayz1zw2rkur9ckn | 40.5 | 3 | 1 | 3 | 0 | 1 | 0 | 0 | 2 | 0 | 33.333333 | 0.000000 | 0.000000 | 66.666667 | 0.0 | 3 | 23.076923 | 1 |
| 1 | e7ty2tbwa1hcmte7ty683aw64pla7689 | 30.5 | 2 | 2 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0.000000 | 33.333333 | 33.333333 | 33.333333 | 0.0 | 3 | 23.076923 | 1 |
| 2 | y139mcxc619h0ooosy139muk14mpfpvm | 30.5 | 2 | 3 | 1 | 0 | 3 | 1 | 0 | 2 | 0 | 100.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 6 | 46.153846 | 1 |
| 3 | pz369rewa2ej3jpz39du46dqedgpnaem | 21.5 | 2 | 1 | 2 | 2 | 1 | 1 | 3 | 3 | 0 | 33.333333 | 33.333333 | 100.000000 | 100.000000 | 0.0 | 8 | 61.538462 | 1 |
| 4 | 6lyvarwdyk7v7hx2qgs6lyyfqalmor05 | 30.5 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 1 | 0 | 66.666667 | 33.333333 | 0.000000 | 33.333333 | 0.0 | 4 | 30.769231 | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | 35zux4sc18rplyz3dc85z35zux4sdfm4 | 21.5 | 2 | 2 | 4 | 500000000 | 1 | 1 | 0 | 1 | 0 | 33.333333 | 33.333333 | 0.000000 | 33.333333 | 0.0 | 3 | 23.076923 | 4 |
| 639 | wn9mk6m1k8o10l1twn9mk6b4z7l7yvhc | 50.5 | 3 | 1 | 3 | 500000000 | 1 | 2 | 3 | 3 | 0 | 33.333333 | 66.666667 | 100.000000 | 100.000000 | 0.0 | 9 | 69.230769 | 4 |
| 640 | oczyh23wpxpk4o0teoczy5zzzng3i6kk | 30.5 | 2 | 2 | 6 | 500000000 | 1 | 2 | 3 | 3 | 0 | 33.333333 | 66.666667 | 100.000000 | 100.000000 | 0.0 | 9 | 69.230769 | 4 |
| 641 | 4udfypw7lf8mmgjmxr4d4udfym4sx1sf | 40.5 | 3 | 1 | 3 | 500000000 | 0 | 0 | 0 | 2 | 1 | 0.000000 | 0.000000 | 0.000000 | 66.666667 | 100.0 | 3 | 23.076923 | 4 |
| 642 | zcj7ldokhyo6217f9sriwizcj7ldodwt | 40.5 | 3 | 2 | 3 | 600000000 | 1 | 3 | 1 | 1 | 0 | 33.333333 | 100.000000 | 33.333333 | 33.333333 | 0.0 | 6 | 46.153846 | 4 |
643 rows × 19 columns
In [28]:
# Absolute mean score for each facet (Sort by Wealth)
df4[['Certainty_3','RiskComprehension_3','Numeracy_3','GraphLiteracy_3','Bayesianreasoning_1','TotalScore_13']].mean(axis = 0).plot(kind = 'bar', title = 'Absolute mean score for each facet (Sort by Wealth)')
Out[28]:
<Axes: title={'center': 'Absolute mean score for each facet (Sort by Wealth)'}>
In [29]:
# Normalised mean score for each facet (Sort by Wealth)
(df4[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%','TotalScore_%']].mean(axis = 0)).plot(kind = 'bar', title = 'Normalised mean score for each facet (Sort by Wealth)')
Out[29]:
<Axes: title={'center': 'Normalised mean score for each facet (Sort by Wealth)'}>
In [30]:
# Line Plot of Absolute Total Facet score vs sorted wealth
df4.plot(use_index = 'True' , kind = 'line', y = ['TotalScore_13'], title = 'Total responses line plot sorted by Wealth',xlabel = 'Unique responses sorted by wealth', ylabel = 'TotalScore_13')
Out[30]:
<Axes: title={'center': 'Total responses line plot sorted by Wealth'}, xlabel='Unique responses sorted by wealth', ylabel='TotalScore_13'>
In [31]:
# Absolute Facet scores line plot from low to high wealth
# I do understand that this is non readable
df4[['Certainty_3','RiskComprehension_3','Numeracy_3','GraphLiteracy_3','Bayesianreasoning_1']].plot( kind = 'line', title = 'Absolute Facet scores line plot', use_index = True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[31]:
<matplotlib.legend.Legend at 0x1f81a52d310>
In [32]:
# Trend line for Absolute Total Facet Score vs unique wealth reponses
sns.regplot (data = df4, x = df4.index, y = 'TotalScore_13')
Out[32]:
<Axes: ylabel='TotalScore_13'>
In [33]:
# Trend line for Absolute Independent Facet Score vs wealth reponses
fig1, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4, x = df4.index, y = 'Certainty_3', fit_reg=True, ci=None, ax=ax1, label='Certainty_3')
sns.regplot (data = df4, x = df4.index, y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax1, label='RiskComprehension_3')
sns.regplot (data = df4, x = df4.index, y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax1, label='Numeracy_3')
sns.regplot (data = df4, x = df4.index, y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax1, label='GraphLiteracy_3')
sns.regplot (data = df4, x = df4.index, y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax1, label='Bayesianreasoning_1' )
ax1.set(ylabel='Scores', xlabel='wealth')
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [34]:
# Count of number of responses under each quartile
df4.groupby('Quartile Number')[['Quartile Number']].count()
Out[34]:
| Quartile Number | |
|---|---|
| Quartile Number | |
| 1 | 161 |
| 2 | 162 |
| 3 | 159 |
| 4 | 161 |
In [35]:
df4.loc[df4['Quartile Number']==1]
Out[35]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | Quartile Number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2rkur9ckjvsyz36zmayz1zw2rkur9ckn | 40.5 | 3 | 1 | 3 | 0 | 1 | 0 | 0 | 2 | 0 | 33.333333 | 0.000000 | 0.000000 | 66.666667 | 0.0 | 3 | 23.076923 | 1 |
| 1 | e7ty2tbwa1hcmte7ty683aw64pla7689 | 30.5 | 2 | 2 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0.000000 | 33.333333 | 33.333333 | 33.333333 | 0.0 | 3 | 23.076923 | 1 |
| 2 | y139mcxc619h0ooosy139muk14mpfpvm | 30.5 | 2 | 3 | 1 | 0 | 3 | 1 | 0 | 2 | 0 | 100.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 6 | 46.153846 | 1 |
| 3 | pz369rewa2ej3jpz39du46dqedgpnaem | 21.5 | 2 | 1 | 2 | 2 | 1 | 1 | 3 | 3 | 0 | 33.333333 | 33.333333 | 100.000000 | 100.000000 | 0.0 | 8 | 61.538462 | 1 |
| 4 | 6lyvarwdyk7v7hx2qgs6lyyfqalmor05 | 30.5 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 1 | 0 | 66.666667 | 33.333333 | 0.000000 | 33.333333 | 0.0 | 4 | 30.769231 | 1 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 156 | qqsa84yklzt7mi9qqsa9kp15tsjflbpn | 30.5 | 2 | 2 | 2 | 350000 | 0 | 1 | 1 | 2 | 1 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 100.0 | 5 | 38.461538 | 1 |
| 157 | sm67z605u7x7he9zjss0qdbjsm67z6wc | 21.5 | 2 | 1 | 3 | 350000 | 1 | 3 | 1 | 0 | 0 | 33.333333 | 100.000000 | 33.333333 | 0.000000 | 0.0 | 5 | 38.461538 | 1 |
| 158 | syhai9qvq3md52xkssyha58qxhgyx7uo | 50.5 | 3 | 1 | 1 | 350000 | 0 | 1 | 2 | 2 | 0 | 0.000000 | 33.333333 | 66.666667 | 66.666667 | 0.0 | 5 | 38.461538 | 1 |
| 159 | p7ung37hpf0ejr08izmp7u2wron7wo0a | 50.5 | 3 | 2 | 2 | 350000 | 1 | 1 | 2 | 3 | 0 | 33.333333 | 33.333333 | 66.666667 | 100.000000 | 0.0 | 7 | 53.846154 | 1 |
| 160 | iywefc200664a8s19oq3viywefc2zav5 | 40.5 | 3 | 1 | 2 | 350000 | 2 | 1 | 2 | 0 | 0 | 66.666667 | 33.333333 | 66.666667 | 0.000000 | 0.0 | 5 | 38.461538 | 1 |
161 rows × 19 columns
In [36]:
# This graph is basically a line plot of the TotalScore_13 across first quartile unique responses which are ordered by income
df4.loc[df4['Quartile Number']==1].plot(use_index = 'True' , kind = 'line', y = ['TotalScore_13'], title = 'Total Score line plot sorted by Wealth Q1',xlabel = 'Unique responses', ylabel = 'TotalScore_13')
Out[36]:
<Axes: title={'center': 'Total Score line plot sorted by Wealth Q1'}, xlabel='Unique responses', ylabel='TotalScore_13'>
In [37]:
# Trend line for Absolute Total Facet Score vs unique Q14. Income reponses in Quartile 1
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'TotalScore_13')
Out[37]:
<Axes: ylabel='TotalScore_13'>
In [38]:
# Trend line for Absolute Independent Facet Score vs wealth reponses in Quartile 1
fig1, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'Certainty_3', fit_reg=True, ci=None, ax=ax2, label='Certainty_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax2, label='RiskComprehension_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax2, label='Numeracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax2, label='GraphLiteracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==1], x = df4.loc[df4['Quartile Number']==1].index, y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax2, label='Bayesianreasoning_1' )
ax2.set(ylabel='Scores', xlabel='wealth')
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [39]:
df4.loc[df4['Quartile Number']==2]
Out[39]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | Quartile Number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 161 | pjshk87e5oqn7cvxupjshkblv1rdybkl | 40.5 | 3 | 3 | 1 | 357000 | 0 | 2 | 2 | 3 | 0 | 0.000000 | 66.666667 | 66.666667 | 100.000000 | 0.0 | 7 | 53.846154 | 2 |
| 162 | mm9er7zx3n18o3lmlgmm9erc50lbg3qs | 40.5 | 3 | 1 | 1 | 375000 | 0 | 2 | 0 | 1 | 0 | 0.000000 | 66.666667 | 0.000000 | 33.333333 | 0.0 | 3 | 23.076923 | 2 |
| 163 | ht7ctpj695gzyrjbt8adwu5eht7ctpj6 | 40.5 | 3 | 2 | 1 | 380000 | 0 | 2 | 0 | 1 | 0 | 0.000000 | 66.666667 | 0.000000 | 33.333333 | 0.0 | 3 | 23.076923 | 2 |
| 164 | nomuxcrlfa5gta9qndnomuxcvravzzyh | 40.5 | 3 | 2 | 1 | 380000 | 0 | 2 | 0 | 2 | 0 | 0.000000 | 66.666667 | 0.000000 | 66.666667 | 0.0 | 4 | 30.769231 | 2 |
| 165 | k2rqe0t5rjl9kb0pk2rqeqqojp9lytra | 30.5 | 2 | 1 | 2 | 399000 | 2 | 1 | 1 | 1 | 0 | 66.666667 | 33.333333 | 33.333333 | 33.333333 | 0.0 | 5 | 38.461538 | 2 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 318 | kkrvshmue24jtdtwj8qkkrvd0jnsfbgx | 30.5 | 2 | 1 | 3 | 1200000 | 0 | 0 | 1 | 1 | 1 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 100.0 | 3 | 23.076923 | 2 |
| 319 | 5zf57p6w5606c4ifg3j5zf57pc53olwd | 30.5 | 2 | 1 | 2 | 1200000 | 0 | 1 | 1 | 0 | 0 | 0.000000 | 33.333333 | 33.333333 | 0.000000 | 0.0 | 2 | 15.384615 | 2 |
| 320 | 8osegw7cma9bwcnp1rze8os0i7fdhvm7 | 30.5 | 2 | 1 | 2 | 1200000 | 0 | 2 | 3 | 3 | 0 | 0.000000 | 66.666667 | 100.000000 | 100.000000 | 0.0 | 8 | 61.538462 | 2 |
| 321 | 24leb8928zk3nvdsb6gll24lebvjrvvk | 30.5 | 2 | 1 | 6 | 1200000 | 0 | 3 | 1 | 3 | 0 | 0.000000 | 100.000000 | 33.333333 | 100.000000 | 0.0 | 7 | 53.846154 | 2 |
| 322 | 9womeewucr9fx6d29womedb3b0jtnum6 | 30.5 | 2 | 1 | 2 | 1200000 | 1 | 1 | 0 | 1 | 0 | 33.333333 | 33.333333 | 0.000000 | 33.333333 | 0.0 | 3 | 23.076923 | 2 |
162 rows × 19 columns
In [40]:
# This graph is basically a line plot of the TotalScore_13 across second quartile unique responses which are ordered by income
df4.loc[df4['Quartile Number']==2].plot(use_index = 'True' , kind = 'line', y = ['TotalScore_13'], title = 'Total Score line plot sorted by Wealth Q1',xlabel = 'Unique responses', ylabel = 'TotalScore_13')
Out[40]:
<Axes: title={'center': 'Total Score line plot sorted by Wealth Q1'}, xlabel='Unique responses', ylabel='TotalScore_13'>
In [41]:
# Trend line for Absolute Total Facet Score vs unique wealth reponses in Quartile 2
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'TotalScore_13')
Out[41]:
<Axes: ylabel='TotalScore_13'>
In [42]:
# Trend line for Absolute Independent Facet Score vs wealth reponses in Quartile 2
fig1, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'Certainty_3', fit_reg=True, ci=None, ax=ax3, label='Certainty_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax3, label='RiskComprehension_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax3, label='Numeracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax3, label='GraphLiteracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==2], x = df4.loc[df4['Quartile Number']==2].index, y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax3, label='Bayesianreasoning_1' )
ax3.set(ylabel='Scores', xlabel='wealth')
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [43]:
df4.loc[df4['Quartile Number']==3]
Out[43]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | Quartile Number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 323 | 7vxwfvymsyuult211ipu7vxwfvqhdcq7 | 50.5 | 3 | 2 | 2 | 1250000 | 1 | 1 | 0 | 2 | 0 | 33.333333 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 4 | 30.769231 | 3 |
| 324 | z1yuu5oonxkvix25a7z1yuugo790vc38 | 21.5 | 2 | 2 | 2 | 1250000 | 0 | 2 | 1 | 3 | 1 | 0.000000 | 66.666667 | 33.333333 | 100.000000 | 100.0 | 7 | 53.846154 | 3 |
| 325 | odfxscnhx6pz1ptrodfxs46gbnyv7ntb | 60.5 | 4 | 1 | 2 | 1250000 | 0 | 1 | 2 | 1 | 1 | 0.000000 | 33.333333 | 66.666667 | 33.333333 | 100.0 | 5 | 38.461538 | 3 |
| 326 | mck3u15th9xjqtg40mck301n03zilmrq | 30.5 | 2 | 1 | 3 | 1280000 | 1 | 0 | 0 | 0 | 0 | 33.333333 | 0.000000 | 0.000000 | 0.000000 | 0.0 | 1 | 7.692308 | 3 |
| 327 | lmf40pcjk28ect1hxa0xlmf40phmawgq | 30.5 | 2 | 1 | 3 | 1300000 | 1 | 0 | 0 | 2 | 0 | 33.333333 | 0.000000 | 0.000000 | 66.666667 | 0.0 | 3 | 23.076923 | 3 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 477 | gpm3fq7g5uy9k9zttsvgpm3fkzsitz4q | 30.5 | 2 | 1 | 2 | 5000000 | 0 | 1 | 3 | 3 | 0 | 0.000000 | 33.333333 | 100.000000 | 100.000000 | 0.0 | 7 | 53.846154 | 3 |
| 478 | bg1xhvcrxugb6h19vbg1psootbgcpo45 | 40.5 | 3 | 2 | 2 | 5000000 | 0 | 2 | 1 | 3 | 1 | 0.000000 | 66.666667 | 33.333333 | 100.000000 | 100.0 | 7 | 53.846154 | 3 |
| 479 | e0ingnzzvib38goe0ingbhmr92mkjker | 30.5 | 2 | 1 | 3 | 5000000 | 2 | 2 | 0 | 0 | 1 | 66.666667 | 66.666667 | 0.000000 | 0.000000 | 100.0 | 5 | 38.461538 | 3 |
| 480 | nvwubouqvv6a9psx6nvwub352o8bqowj | 21.5 | 2 | 1 | 5 | 5000000 | 0 | 1 | 2 | 2 | 1 | 0.000000 | 33.333333 | 66.666667 | 66.666667 | 100.0 | 6 | 46.153846 | 3 |
| 481 | obftinjncjw2fkari22ghobfti6alubg | 30.5 | 2 | 1 | 3 | 5200000 | 0 | 1 | 3 | 3 | 0 | 0.000000 | 33.333333 | 100.000000 | 100.000000 | 0.0 | 7 | 53.846154 | 3 |
159 rows × 19 columns
In [44]:
# This graph is basically a line plot of the TotalScore_13 across third quartile unique responses which are ordered by wealth
df4.loc[df4['Quartile Number']==3].plot(use_index = 'True' , kind = 'line', y = ['TotalScore_13'], title = 'Total Score line plot sorted by Wealth Q3',xlabel = 'Unique responses', ylabel = 'TotalScore_13')
Out[44]:
<Axes: title={'center': 'Total Score line plot sorted by Wealth Q3'}, xlabel='Unique responses', ylabel='TotalScore_13'>
In [45]:
# Trend line for Absolute Total Facet Score vs unique wealth reponses in Quartile 3
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'TotalScore_13')
Out[45]:
<Axes: ylabel='TotalScore_13'>
In [46]:
# Trend line for Absolute Independent Facet Score vs wealth reponses in Quartile 3
fig1, ax4 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'Certainty_3', fit_reg=True, ci=None, ax=ax4, label='Certainty_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax4, label='RiskComprehension_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax4, label='Numeracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax4, label='GraphLiteracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==3], x = df4.loc[df4['Quartile Number']==3].index, y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax4, label='Bayesianreasoning_1' )
ax4.set(ylabel='Scores', xlabel='wealth')
ax4.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [47]:
df4.loc[df4['Quartile Number']==4]
Out[47]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | Quartile Number | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 482 | rh3ida1re0oohl9crh3ida1s6gcynlil | 30.5 | 2 | 1 | 4 | 5245899 | 3 | 0 | 1 | 1 | 0 | 100.000000 | 0.000000 | 33.333333 | 33.333333 | 0.0 | 5 | 38.461538 | 4 |
| 483 | fa4fw88qzaxzjxw31rzchtfa4fw8gn8h | 30.5 | 2 | 1 | 3 | 5500000 | 2 | 1 | 0 | 2 | 0 | 66.666667 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 5 | 38.461538 | 4 |
| 484 | 8pwy5gq2mcpugpldx8pwy5javd312pha | 30.5 | 2 | 1 | 3 | 5500000 | 1 | 1 | 0 | 3 | 0 | 33.333333 | 33.333333 | 0.000000 | 100.000000 | 0.0 | 5 | 38.461538 | 4 |
| 485 | gdsir9721na619gpfsu9jqk7bi4rhpfs | 30.5 | 2 | 2 | 3 | 5500000 | 1 | 3 | 2 | 2 | 1 | 33.333333 | 100.000000 | 66.666667 | 66.666667 | 100.0 | 9 | 69.230769 | 4 |
| 486 | ks6mtnxelurtt3m3uihks6mtnlo5k2i3 | 30.5 | 2 | 2 | 1 | 5800000 | 0 | 0 | 2 | 3 | 0 | 0.000000 | 0.000000 | 66.666667 | 100.000000 | 0.0 | 5 | 38.461538 | 4 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | 35zux4sc18rplyz3dc85z35zux4sdfm4 | 21.5 | 2 | 2 | 4 | 500000000 | 1 | 1 | 0 | 1 | 0 | 33.333333 | 33.333333 | 0.000000 | 33.333333 | 0.0 | 3 | 23.076923 | 4 |
| 639 | wn9mk6m1k8o10l1twn9mk6b4z7l7yvhc | 50.5 | 3 | 1 | 3 | 500000000 | 1 | 2 | 3 | 3 | 0 | 33.333333 | 66.666667 | 100.000000 | 100.000000 | 0.0 | 9 | 69.230769 | 4 |
| 640 | oczyh23wpxpk4o0teoczy5zzzng3i6kk | 30.5 | 2 | 2 | 6 | 500000000 | 1 | 2 | 3 | 3 | 0 | 33.333333 | 66.666667 | 100.000000 | 100.000000 | 0.0 | 9 | 69.230769 | 4 |
| 641 | 4udfypw7lf8mmgjmxr4d4udfym4sx1sf | 40.5 | 3 | 1 | 3 | 500000000 | 0 | 0 | 0 | 2 | 1 | 0.000000 | 0.000000 | 0.000000 | 66.666667 | 100.0 | 3 | 23.076923 | 4 |
| 642 | zcj7ldokhyo6217f9sriwizcj7ldodwt | 40.5 | 3 | 2 | 3 | 600000000 | 1 | 3 | 1 | 1 | 0 | 33.333333 | 100.000000 | 33.333333 | 33.333333 | 0.0 | 6 | 46.153846 | 4 |
161 rows × 19 columns
In [48]:
# This graph is basically a line plot of the TotalScore_13 across fourth quartile unique responses which are ordered by Wealth
df4.loc[df4['Quartile Number']==4].plot(use_index = 'True' , kind = 'line', y = ['TotalScore_13'], title = 'Total Score line plot sorted by Wealth Q4',xlabel = 'Unique responses', ylabel = 'TotalScore_13')
Out[48]:
<Axes: title={'center': 'Total Score line plot sorted by Wealth Q4'}, xlabel='Unique responses', ylabel='TotalScore_13'>
In [49]:
# Trend line for Absolute Total Facet Score vs unique wealth reponses in Quartile 4
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'TotalScore_13')
Out[49]:
<Axes: ylabel='TotalScore_13'>
In [50]:
# Trend line for Absolute Independent Facet Score vs wealth reponses in Quartile 4
fig1, ax5 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'Certainty_3', fit_reg=True, ci=None, ax=ax5, label='Certainty_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax5, label='RiskComprehension_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax5, label='Numeracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax5, label='GraphLiteracy_3')
sns.regplot (data = df4.loc[df4['Quartile Number']==4], x = df4.loc[df4['Quartile Number']==4].index, y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax5, label='Bayesianreasoning_1' )
ax5.set(ylabel='Scores', xlabel='wealth')
ax5.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [ ]:
In [51]:
# Absolute Total Facet scores mean line plot from low to high Wealth
df4.groupby('Quartile Number')[['TotalScore_13']].mean().plot( kind = 'line', title = 'Absolute Total Facet scores mean line plot low to high wealth', xticks = np.arange(1,5,step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[51]:
<matplotlib.legend.Legend at 0x1f81ccf0390>
In [52]:
# Absolute Facet scores mean line plot from low to high wealth
df4.groupby('Quartile Number')[['Certainty_3','RiskComprehension_3','Numeracy_3','GraphLiteracy_3','Bayesianreasoning_1']].mean().plot( kind = 'line', title = 'Absolute Facet scores mean line plot low to high wealth', xticks = np.arange(1,5,step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[52]:
<matplotlib.legend.Legend at 0x1f81c38c290>
In [53]:
# Normalised Facet scores mean line plot from low to high wealth
df4.groupby('Quartile Number')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%','TotalScore_%']].mean().plot( kind = 'line', title = 'Normalised Facet scores mean line plot from low to high wealth', xticks = np.arange(1,5,step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[53]:
<matplotlib.legend.Legend at 0x1f81c69a410>
In [54]:
# Normalised mean scores for each facet stacked
df4.groupby('Quartile Number')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%']].mean().plot( kind = 'bar', title = 'Normalised mean scores for each facet stacked', stacked = True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[54]:
<matplotlib.legend.Legend at 0x1f81cce0410>
In [55]:
# Normalised mean scores for each facet for each wealth response Quartile
df4.groupby('Quartile Number')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%','TotalScore_%']].mean().T.plot(kind = 'bar', title = 'Normalised mean scores for each facet for each wealth response category').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[55]:
<matplotlib.legend.Legend at 0x1f81ce91290>
In [56]:
# Trend line for Absolute Total Facet Score vs Quartiles
sns.regplot (data = df4, x = 'Quartile Number', y = 'TotalScore_13')
Out[56]:
<Axes: xlabel='Quartile Number', ylabel='TotalScore_13'>
In [57]:
# Trend line for Absolute Independent Facet Score vs Quartiles
fig2, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df4, x = 'Quartile Number', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax2, label='Certainty_3')
sns.regplot (data = df4, x = 'Quartile Number', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax2, label='RiskComprehension_3')
sns.regplot (data = df4, x = 'Quartile Number', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax2, label='Numeracy_3')
sns.regplot (data = df4, x = 'Quartile Number', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax2, label='GraphLiteracy_3')
sns.regplot (data = df4, x = 'Quartile Number', y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax2, label='Bayesianreasoning_1' )
ax2.set(ylabel='Scores', xlabel='wealth')
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [58]:
# Violine Plot for TotalScore_13 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'TotalScore_13')
Out[58]:
<Axes: xlabel='Quartile Number', ylabel='TotalScore_13'>
In [59]:
# Violine Plot for Certainty_3 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'Certainty_3')
Out[59]:
<Axes: xlabel='Quartile Number', ylabel='Certainty_3'>
In [60]:
# Violine Plot for RiskComprehension_3 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'RiskComprehension_3')
Out[60]:
<Axes: xlabel='Quartile Number', ylabel='RiskComprehension_3'>
In [61]:
# Violine Plot for GraphLiteracy_3 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'GraphLiteracy_3')
Out[61]:
<Axes: xlabel='Quartile Number', ylabel='GraphLiteracy_3'>
In [62]:
# Violine Plot for Numeracy_3 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'Numeracy_3')
Out[62]:
<Axes: xlabel='Quartile Number', ylabel='Numeracy_3'>
In [63]:
# Violine Plot for Bayesianreasoning_1 for each entry under Wealth Quartiles.
sns.violinplot( data = df4, x = 'Quartile Number', y = 'Bayesianreasoning_1')
Out[63]:
<Axes: xlabel='Quartile Number', ylabel='Bayesianreasoning_1'>
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [64]:
# Data Frame 5 or df5 is an aggregate data on facet total scores and over all total score, along with education data vs each response.
# This data set is now sorted by education.
df5 = df2.sort_values(by = 'isced')
df5 = df5.reset_index(drop = True)
df5
Out[64]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ztfdlcbiyo1xco3ztfdl4ozqpte2q3m9 | 30.5 | 2 | 1 | 3 | 5000000 | 1 | 2 | 1 | 3 | 0 | 33.333333 | 66.666667 | 33.333333 | 100.000000 | 0.0 | 7 | 53.846154 |
| 1 | ten07h1k6r3hqcfqten07isxh8g3c7sd | 30.5 | 2 | 1 | 2 | 500000 | 0 | 0 | 0 | 3 | 0 | 0.000000 | 0.000000 | 0.000000 | 100.000000 | 0.0 | 3 | 23.076923 |
| 2 | h5ngv0k7kcqx5i5qoftgxh5ngv0k7fvv | 30.5 | 2 | 1 | 2 | 500000 | 1 | 2 | 0 | 0 | 0 | 33.333333 | 66.666667 | 0.000000 | 0.000000 | 0.0 | 3 | 23.076923 |
| 3 | h5n6a65bgsz5w1mi1inh5n6a7l54vger | 40.5 | 3 | 1 | 2 | 30000 | 1 | 1 | 3 | 0 | 0 | 33.333333 | 33.333333 | 100.000000 | 0.000000 | 0.0 | 5 | 38.461538 |
| 4 | tftzv0n6j9gvvxwm68xtftzv0hvv1e1m | 30.5 | 2 | 1 | 6 | 20000000 | 0 | 0 | 0 | 0 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 | 0 | 0.000000 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | y139mcxc619h0ooosy139muk14mpfpvm | 30.5 | 2 | 3 | 1 | 0 | 3 | 1 | 0 | 2 | 0 | 100.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 6 | 46.153846 |
| 639 | mj52mssq166g3wubcnkmj520tfdzf8oz | 40.5 | 3 | 3 | 1 | 2000 | 1 | 1 | 1 | 2 | 0 | 33.333333 | 33.333333 | 33.333333 | 66.666667 | 0.0 | 5 | 38.461538 |
| 640 | a31qwuv5yj3n5tlmea3183d7y7salhcl | 30.5 | 2 | 3 | 1 | 5000000 | 0 | 1 | 0 | 2 | 0 | 0.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 3 | 23.076923 |
| 641 | 870h2qs77chp1cd5q870n4fnkjbrxezk | 21.5 | 2 | 3 | 2 | 150000 | 0 | 1 | 0 | 0 | 0 | 0.000000 | 33.333333 | 0.000000 | 0.000000 | 0.0 | 1 | 7.692308 |
| 642 | t1hiz7zjzou3pfd59pqt1hizrglay7e5 | 40.5 | 3 | 3 | 1 | 200000 | 1 | 1 | 2 | 1 | 0 | 33.333333 | 33.333333 | 66.666667 | 33.333333 | 0.0 | 5 | 38.461538 |
643 rows × 18 columns
In [65]:
# since we didnt drop any values, the dataset is essentially the same as df2, but sorted
In [66]:
# Mean of each facet as a % for each category of isced
df5.groupby('isced')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%']].mean()
Out[66]:
| Certainty_% | RiskComprehension_% | Numeracy_% | GraphLiteracy_% | Bayesianreasoning_% | |
|---|---|---|---|---|---|
| isced | |||||
| 1 | 19.423868 | 39.588477 | 56.707819 | 40.000000 | 24.444444 |
| 2 | 19.444444 | 41.512346 | 59.259259 | 39.351852 | 29.629630 |
| 3 | 31.818182 | 30.303030 | 53.030303 | 33.333333 | 9.090909 |
In [67]:
# Count of responses for each category isced
df5.groupby('isced')[['ResponseId']].count()
Out[67]:
| ResponseId | |
|---|---|
| isced | |
| 1 | 405 |
| 2 | 216 |
| 3 | 22 |
In [68]:
# Absolute Total Facet scores mean line plot from low to high education
df5.groupby('isced')[['TotalScore_13']].mean().plot( kind = 'line', title = 'Absolute Total Facet scores mean line plot', xticks = np.arange(1,4, step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[68]:
<matplotlib.legend.Legend at 0x1f81ed9e8d0>
In [69]:
# Absolute Facet scores mean line plot from low to high edu
df5.groupby('isced')[['Certainty_3','RiskComprehension_3','Numeracy_3','GraphLiteracy_3','Bayesianreasoning_1']].mean().plot( kind = 'line', title = 'Absolute Facet scores mean line plot', xticks = np.arange(1,4, step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[69]:
<matplotlib.legend.Legend at 0x1f81eeb15d0>
In [70]:
# Normalised Facet scores mean line plot from low to high edu
df5.groupby('isced')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%','TotalScore_%']].mean().plot( kind = 'line', title = 'Normalised Facet scores mean line plot', xticks = np.arange(1,4, step = 1)).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[70]:
<matplotlib.legend.Legend at 0x1f81ef63450>
In [71]:
# Normalised mean scores for each facet stacked
df5.groupby('isced')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%']].mean().plot( kind = 'bar', title = 'Normalised mean scores for each facet stacked', stacked = True).legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[71]:
<matplotlib.legend.Legend at 0x1f81efc2790>
In [72]:
# Normalised mean scores for each facet for each edu response category
df5.groupby('isced')[['Certainty_%','RiskComprehension_%','Numeracy_%','GraphLiteracy_%','Bayesianreasoning_%','TotalScore_%']].mean().T.plot(kind = 'bar', title = 'Normalised mean scores for each facet for each edu response category').legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
Out[72]:
<matplotlib.legend.Legend at 0x1f81f2b1750>
In [73]:
# Trend line for Absolute Total Facet Score vs edu (isced) reponses
sns.regplot (data = df5, x = 'isced', y = 'TotalScore_13')
Out[73]:
<Axes: xlabel='isced', ylabel='TotalScore_13'>
In [74]:
# Trend line for Absolute Independent Facet Score vs edu (isced) reponses
fig, ax6 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df5, x = 'isced', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax6, label='Certainty_3')
sns.regplot (data = df5, x = 'isced', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax6, label='RiskComprehension_3')
sns.regplot (data = df5, x = 'isced', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax6, label='Numeracy_3')
sns.regplot (data = df5, x = 'isced', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax6, label='GraphLiteracy_3')
sns.regplot (data = df5, x = 'isced', y = 'Bayesianreasoning_1',fit_reg=True, ci=None, ax=ax6, label='Bayesianreasoning_1' )
ax6.set(ylabel='Scores', xlabel='isced')
ax6.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [75]:
# Violine Plot for TotalScore_13 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'TotalScore_13')
Out[75]:
<Axes: xlabel='isced', ylabel='TotalScore_13'>
In [76]:
# Violine Plot for Certainty_3 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'Certainty_3')
Out[76]:
<Axes: xlabel='isced', ylabel='Certainty_3'>
In [77]:
# Violine Plot for RiskComprehension_3 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'RiskComprehension_3')
Out[77]:
<Axes: xlabel='isced', ylabel='RiskComprehension_3'>
In [78]:
# Violine Plot for GraphLiteracy_3 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'GraphLiteracy_3')
Out[78]:
<Axes: xlabel='isced', ylabel='GraphLiteracy_3'>
In [79]:
# Violine Plot for Numeracy_3 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'Numeracy_3')
Out[79]:
<Axes: xlabel='isced', ylabel='Numeracy_3'>
In [80]:
# Violine Plot for TotalScore_13 for each entry under edu.
sns.violinplot( data = df5, x = 'isced', y = 'Bayesianreasoning_1')
Out[80]:
<Axes: xlabel='isced', ylabel='Bayesianreasoning_1'>
In [81]:
# Descriptive stats for the data set, isced = 1
# NA values of wealth are removed
df6 = df5.dropna(axis = 0, subset = 'wealth')
# df6.drop(df6[df6['wealth'] == 3500000].index, inplace = True)
df6.loc[df6['isced']==1][['wealth']].describe()
Out[81]:
| wealth | |
|---|---|
| count | 4.050000e+02 |
| mean | 1.220912e+07 |
| std | 4.537261e+07 |
| min | 0.000000e+00 |
| 25% | 5.000000e+05 |
| 50% | 1.700000e+06 |
| 75% | 7.500000e+06 |
| max | 5.000000e+08 |
In [82]:
# Descriptive stats for the data set, isced = 2
df6.loc[df6['isced']==2][['wealth']].describe()
Out[82]:
| wealth | |
|---|---|
| count | 2.160000e+02 |
| mean | 1.355720e+07 |
| std | 6.621355e+07 |
| min | 0.000000e+00 |
| 25% | 3.375000e+05 |
| 50% | 9.999500e+05 |
| 75% | 5.000000e+06 |
| max | 6.000000e+08 |
In [83]:
# Descriptive stats for the data set, isced = 3
df6.loc[df6['isced']==3][['wealth']].describe()
Out[83]:
| wealth | |
|---|---|
| count | 2.200000e+01 |
| mean | 3.038705e+06 |
| std | 7.097479e+06 |
| min | 0.000000e+00 |
| 25% | 3.500000e+04 |
| 50% | 2.000000e+05 |
| 75% | 1.650125e+06 |
| max | 3.000000e+07 |
In [84]:
# Trend line for Absolute Tota Facet Score vs wealth reponses sorted by isced and ORDERED by wealth WITH scatter
fig, ax7 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax7, label='ISCED = 1')
sns.regplot (data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax7, label='ISCED = 2')
sns.regplot (data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax7, label='ISCED = 3')
ax7.set(ylabel='Total Scores_19', xlabel='Wealth')
ax7.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [85]:
# Trend line for Absolute Tota Facet Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax8 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 3')
ax8.set(ylabel='Total Scores_19', xlabel='Wealth')
ax8.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [86]:
# Trend line for Absolute Certainty Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax9 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 3')
ax9.set(ylabel='Certainty_3', xlabel='Wealth')
ax9.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [87]:
# Trend line for Absolute Uncertainty Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax10 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 3')
ax10.set(ylabel='RiskComprehension_3', xlabel='Wealth')
ax10.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [88]:
# Trend line for Absolute Number Comprehension Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax11 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 3')
ax11.set(ylabel='Numeracy_3', xlabel='Wealth')
ax11.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [89]:
# Trend line for Absolute Graph Comprehension Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax11 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 3')
ax11.set(ylabel='GraphLiteracy_3', xlabel='Wealth')
ax11.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [90]:
# Trend line for Absolute Bayesian Reasoning Score vs wealth reponses sorted by isced and ORDERED by wealth WITHOUT scatter
fig, ax12 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df6.loc[df6['isced']==1].reset_index(drop = True), x = df6.loc[df6['isced']==1].reset_index(drop = True)['wealth'], y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 1')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==2].reset_index(drop = True), x = df6.loc[df6['isced']==2].reset_index(drop = True)['wealth'], y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 2')
sns.regplot (scatter = False, data = df6.loc[df6['isced']==3].reset_index(drop = True), x = df6.loc[df6['isced']==3].reset_index(drop = True)['wealth'], y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 3')
ax12.set(ylabel='Bayesianreasoning_1', xlabel='Wealth')
ax12.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [ ]:
In [ ]:
In [91]:
# Descriptive stats for the data set, isced = 1
# NA values of income are removed
df7 = df5
df7.drop(df7[df7['income'] == 7].index, inplace = True)
df7.loc[df7['isced']==1].describe()
Out[91]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 405.000000 | 405.000000 | 405.0 | 405.000000 | 4.050000e+02 | 405.000000 | 405.000000 | 405.00000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 | 405.000000 |
| mean | 35.337037 | 2.446914 | 1.0 | 2.760494 | 1.220912e+07 | 0.582716 | 1.187654 | 1.20000 | 1.701235 | 0.244444 | 19.423868 | 39.588477 | 40.000000 | 56.707819 | 24.444444 | 4.916049 | 37.815764 |
| std | 9.171529 | 0.563117 | 0.0 | 1.338471 | 4.537261e+07 | 0.745413 | 0.889624 | 0.96061 | 1.032695 | 0.430289 | 24.847113 | 29.654143 | 32.020346 | 34.423165 | 43.028887 | 2.212222 | 17.017090 |
| min | 21.500000 | 2.000000 | 1.0 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 30.500000 | 2.000000 | 1.0 | 2.000000 | 5.000000e+05 | 0.000000 | 1.000000 | 0.00000 | 1.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 33.333333 | 0.000000 | 3.000000 | 23.076923 |
| 50% | 30.500000 | 2.000000 | 1.0 | 2.000000 | 1.700000e+06 | 0.000000 | 1.000000 | 1.00000 | 2.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 40.500000 | 3.000000 | 1.0 | 3.000000 | 7.500000e+06 | 1.000000 | 2.000000 | 2.00000 | 3.000000 | 0.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 0.000000 | 7.000000 | 53.846154 |
| max | 70.500000 | 4.000000 | 1.0 | 6.000000 | 5.000000e+08 | 3.000000 | 3.000000 | 3.00000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 11.000000 | 84.615385 |
In [92]:
df7.loc[df7['isced']==2].describe()
Out[92]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 216.000000 | 216.000000 | 216.0 | 216.000000 | 2.160000e+02 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 | 216.000000 |
| mean | 33.634259 | 2.375000 | 2.0 | 2.166667 | 1.355720e+07 | 0.583333 | 1.245370 | 1.180556 | 1.777778 | 0.296296 | 19.444444 | 41.512346 | 39.351852 | 59.259259 | 29.629630 | 5.083333 | 39.102564 |
| std | 10.135158 | 0.564966 | 0.0 | 1.204642 | 6.621355e+07 | 0.754829 | 0.940053 | 0.930012 | 0.958034 | 0.457684 | 25.160980 | 31.335096 | 31.000403 | 31.934472 | 45.768394 | 2.208335 | 16.987194 |
| min | 21.500000 | 2.000000 | 2.0 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 30.500000 | 2.000000 | 2.0 | 1.000000 | 3.375000e+05 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 4.000000 | 30.769231 |
| 50% | 30.500000 | 2.000000 | 2.0 | 2.000000 | 9.999500e+05 | 0.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 40.500000 | 3.000000 | 2.0 | 2.000000 | 5.000000e+06 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 1.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 100.000000 | 6.000000 | 46.153846 |
| max | 60.500000 | 4.000000 | 2.0 | 6.000000 | 6.000000e+08 | 3.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 10.000000 | 76.923077 |
In [93]:
df7.loc[df7['isced']==3].describe()
Out[93]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 22.000000 | 22.000000 | 22.0 | 22.000000 | 2.200000e+01 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 | 22.000000 |
| mean | 36.681818 | 2.590909 | 3.0 | 1.454545 | 3.038705e+06 | 0.954545 | 0.909091 | 1.000000 | 1.590909 | 0.090909 | 31.818182 | 30.303030 | 33.333333 | 53.030303 | 9.090909 | 4.545455 | 34.965035 |
| std | 14.384636 | 0.666125 | 0.0 | 0.857864 | 7.097479e+06 | 0.898532 | 0.750180 | 1.112697 | 1.181568 | 0.294245 | 29.951058 | 25.006012 | 37.089909 | 39.385614 | 29.424494 | 2.482842 | 19.098781 |
| min | 21.500000 | 2.000000 | 3.0 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 23.750000 | 2.000000 | 3.0 | 1.000000 | 3.500000e+04 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 3.000000 | 23.076923 |
| 50% | 35.500000 | 2.500000 | 3.0 | 1.000000 | 2.000000e+05 | 1.000000 | 1.000000 | 1.000000 | 1.500000 | 0.000000 | 33.333333 | 33.333333 | 33.333333 | 50.000000 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 40.500000 | 3.000000 | 3.0 | 1.750000 | 1.650125e+06 | 1.000000 | 1.000000 | 2.000000 | 3.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 100.000000 | 0.000000 | 6.000000 | 46.153846 |
| max | 70.500000 | 4.000000 | 3.0 | 4.000000 | 3.000000e+07 | 3.000000 | 2.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 66.666667 | 100.000000 | 100.000000 | 100.000000 | 9.000000 | 69.230769 |
In [94]:
# Trend line for Absolute Tota Facet Score vs income reponses sorted by isced and ORDERED by income WITH scatter
fig, ax7 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = df7.loc[df7['isced']==1]['TotalScore_13'], fit_reg=True, ci=None, ax=ax7, label='ISCED = 1')
sns.regplot (data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = df7.loc[df7['isced']==2]['TotalScore_13'], fit_reg=True, ci=None, ax=ax7, label='ISCED = 2')
sns.regplot (data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = df7.loc[df7['isced']==3]['TotalScore_13'], fit_reg=True, ci=None, ax=ax7, label='ISCED = 3')
ax7.set(ylabel='Total Scores_19', xlabel='INCOME')
ax7.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [95]:
# Trend line for Absolute Tota Facet Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax8 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'TotalScore_13', fit_reg=True, ci=None, ax=ax8, label='ISCED = 3')
ax8.set(ylabel='Total Scores_19', xlabel='INCOME')
ax8.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [96]:
# Trend line for Absolute Certainty Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax9 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'Certainty_3', fit_reg=True, ci=None, ax=ax9, label='ISCED = 3')
ax9.set(ylabel='Certainty_3', xlabel='INCOME')
ax9.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [97]:
# Trend line for Absolute Risk Comprehension Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax10 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'RiskComprehension_3', fit_reg=True, ci=None, ax=ax10, label='ISCED = 3')
ax10.set(ylabel='RiskComprehension_3', xlabel='INCOME')
ax10.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [98]:
# Trend line for Absolute Number Comprehension Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax11 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'Numeracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 3')
ax11.set(ylabel='Numeracy_3', xlabel='INCOME')
ax11.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [99]:
# Trend line for Absolute Graph Comprehension Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax11 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'GraphLiteracy_3', fit_reg=True, ci=None, ax=ax11, label='ISCED = 3')
ax11.set(ylabel='GraphLiteracy_3', xlabel='INCOME')
ax11.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [100]:
# Trend line for Absolute Bayesian Reasoning Score vs income reponses sorted by isced and ORDERED by income WITHOUT scatter
fig, ax12 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[df7['isced']==1].reset_index(drop = True), x = 'income', y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==2].reset_index(drop = True), x = 'income', y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[df7['isced']==3].reset_index(drop = True), x = 'income', y = 'Bayesianreasoning_1', fit_reg=True, ci=None, ax=ax12, label='ISCED = 3')
ax12.set(ylabel='Bayesianreasoning_1', xlabel='INCOME')
ax12.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [ ]:
In [ ]:
In [101]:
df7
Out[101]:
| ResponseId | age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ztfdlcbiyo1xco3ztfdl4ozqpte2q3m9 | 30.5 | 2 | 1 | 3 | 5000000 | 1 | 2 | 1 | 3 | 0 | 33.333333 | 66.666667 | 33.333333 | 100.000000 | 0.0 | 7 | 53.846154 |
| 1 | ten07h1k6r3hqcfqten07isxh8g3c7sd | 30.5 | 2 | 1 | 2 | 500000 | 0 | 0 | 0 | 3 | 0 | 0.000000 | 0.000000 | 0.000000 | 100.000000 | 0.0 | 3 | 23.076923 |
| 2 | h5ngv0k7kcqx5i5qoftgxh5ngv0k7fvv | 30.5 | 2 | 1 | 2 | 500000 | 1 | 2 | 0 | 0 | 0 | 33.333333 | 66.666667 | 0.000000 | 0.000000 | 0.0 | 3 | 23.076923 |
| 3 | h5n6a65bgsz5w1mi1inh5n6a7l54vger | 40.5 | 3 | 1 | 2 | 30000 | 1 | 1 | 3 | 0 | 0 | 33.333333 | 33.333333 | 100.000000 | 0.000000 | 0.0 | 5 | 38.461538 |
| 4 | tftzv0n6j9gvvxwm68xtftzv0hvv1e1m | 30.5 | 2 | 1 | 6 | 20000000 | 0 | 0 | 0 | 0 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.0 | 0 | 0.000000 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 638 | y139mcxc619h0ooosy139muk14mpfpvm | 30.5 | 2 | 3 | 1 | 0 | 3 | 1 | 0 | 2 | 0 | 100.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 6 | 46.153846 |
| 639 | mj52mssq166g3wubcnkmj520tfdzf8oz | 40.5 | 3 | 3 | 1 | 2000 | 1 | 1 | 1 | 2 | 0 | 33.333333 | 33.333333 | 33.333333 | 66.666667 | 0.0 | 5 | 38.461538 |
| 640 | a31qwuv5yj3n5tlmea3183d7y7salhcl | 30.5 | 2 | 3 | 1 | 5000000 | 0 | 1 | 0 | 2 | 0 | 0.000000 | 33.333333 | 0.000000 | 66.666667 | 0.0 | 3 | 23.076923 |
| 641 | 870h2qs77chp1cd5q870n4fnkjbrxezk | 21.5 | 2 | 3 | 2 | 150000 | 0 | 1 | 0 | 0 | 0 | 0.000000 | 33.333333 | 0.000000 | 0.000000 | 0.0 | 1 | 7.692308 |
| 642 | t1hiz7zjzou3pfd59pqt1hizrglay7e5 | 40.5 | 3 | 3 | 1 | 200000 | 1 | 1 | 2 | 1 | 0 | 33.333333 | 33.333333 | 66.666667 | 33.333333 | 0.0 | 5 | 38.461538 |
643 rows × 18 columns
In [102]:
# Since we already have a classification for Age groups in the form of age_rec, we will use that.
# We will also use median of age to see if it yields any relevant results, as instructed.
# AXES to be used = Age or age groups, ISCED, Income
# Age groups = [2,3,4]
# Age group 2 = 18 to 35 y/o
# Age group 3 = 36 to 59 y/o
# Age group 4 = 60 to 75 y/o (75 y/o, i.e, within the scope of the data we have, it can mean 60 and above also)
In [103]:
df7.loc[(df7['age_rec']==2)].describe()
Out[103]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 393.000000 | 393.0 | 393.000000 | 393.000000 | 3.930000e+02 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 |
| mean | 28.393130 | 2.0 | 1.422392 | 2.394402 | 9.461581e+06 | 0.552163 | 1.195929 | 1.165394 | 1.712468 | 0.244275 | 18.405428 | 39.864292 | 38.846480 | 57.082273 | 24.427481 | 4.870229 | 37.463300 |
| std | 3.815754 | 0.0 | 0.548381 | 1.241160 | 4.116973e+07 | 0.737447 | 0.917396 | 0.931656 | 1.028310 | 0.430204 | 24.581570 | 30.579878 | 31.055203 | 34.276987 | 43.020409 | 2.154955 | 16.576576 |
| min | 21.500000 | 2.0 | 1.000000 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 30.500000 | 2.0 | 1.000000 | 2.000000 | 3.000000e+05 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 3.000000 | 23.076923 |
| 50% | 30.500000 | 2.0 | 1.000000 | 2.000000 | 1.000000e+06 | 0.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 30.500000 | 2.0 | 2.000000 | 3.000000 | 5.000000e+06 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 0.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 0.000000 | 7.000000 | 53.846154 |
| max | 30.500000 | 2.0 | 3.000000 | 6.000000 | 5.000000e+08 | 3.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 10.000000 | 76.923077 |
In [104]:
df7.loc[(df7['age_rec']==3)].describe()
Out[104]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 225.000000 | 225.0 | 225.000000 | 225.000000 | 2.250000e+02 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 | 225.000000 |
| mean | 42.900000 | 3.0 | 1.360000 | 2.768889 | 1.742734e+07 | 0.662222 | 1.195556 | 1.177778 | 1.746667 | 0.271111 | 22.074074 | 39.851852 | 39.259259 | 58.222222 | 27.111111 | 5.053333 | 38.871795 |
| std | 4.280354 | 0.0 | 0.558378 | 1.423624 | 6.999865e+07 | 0.797118 | 0.889913 | 0.988525 | 0.983253 | 0.445524 | 26.570594 | 29.663753 | 32.950848 | 32.775087 | 44.552448 | 2.327399 | 17.903069 |
| min | 40.500000 | 3.0 | 1.000000 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 40.500000 | 3.0 | 1.000000 | 2.000000 | 3.800000e+05 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 33.333333 | 0.000000 | 3.000000 | 23.076923 |
| 50% | 40.500000 | 3.0 | 1.000000 | 2.000000 | 2.500000e+06 | 0.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 40.500000 | 3.0 | 2.000000 | 3.000000 | 7.800000e+06 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 1.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 100.000000 | 7.000000 | 53.846154 |
| max | 50.500000 | 3.0 | 3.000000 | 6.000000 | 6.000000e+08 | 3.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 11.000000 | 84.615385 |
In [105]:
df7.loc[(df7['age_rec']==4)].describe()
Out[105]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 25.000000 | 25.0 | 25.000000 | 25.000000 | 2.500000e+01 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 | 25.000000 |
| mean | 62.900000 | 4.0 | 1.520000 | 2.160000 | 1.201400e+07 | 0.680000 | 1.240000 | 1.600000 | 1.680000 | 0.320000 | 22.666667 | 41.333333 | 53.333333 | 56.000000 | 32.000000 | 5.520000 | 42.461538 |
| std | 4.358899 | 0.0 | 0.653197 | 1.374773 | 1.651268e+07 | 0.627163 | 0.830662 | 0.957427 | 1.069268 | 0.476095 | 20.905431 | 27.688746 | 31.914237 | 35.642255 | 47.609523 | 2.200757 | 16.928903 |
| min | 60.500000 | 4.0 | 1.000000 | 1.000000 | 1.000000e+05 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 2.000000 | 15.384615 |
| 25% | 60.500000 | 4.0 | 1.000000 | 1.000000 | 2.000000e+06 | 0.000000 | 1.000000 | 1.000000 | 1.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 33.333333 | 0.000000 | 4.000000 | 30.769231 |
| 50% | 60.500000 | 4.0 | 1.000000 | 2.000000 | 5.000000e+06 | 1.000000 | 1.000000 | 2.000000 | 1.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 33.333333 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 60.500000 | 4.0 | 2.000000 | 2.000000 | 1.000000e+07 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 1.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 100.000000 | 8.000000 | 61.538462 |
| max | 70.500000 | 4.0 | 3.000000 | 6.000000 | 5.250000e+07 | 2.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 66.666667 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 9.000000 | 69.230769 |
In [ ]:
In [106]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='Total Scores_14', xlabel='INCOME 18 to 35')
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Total Scores_14', xlabel='INCOME 36 to 59')
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='Total Scores_14', xlabel='INCOME 60 to 75')
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [107]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income']).mean(numeric_only=True)['TotalScore_13'], yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['TotalScore_13'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='Total Scores_14', xlabel='INCOME 18 to 35', yticks = np.arange(5, 16 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Total Scores_14', xlabel='INCOME 36 to 59', yticks = np.arange(5, 16 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income']).mean(numeric_only=True)['TotalScore_13'], yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['TotalScore_13'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='Total Scores_14', xlabel='INCOME 60 to 75', yticks = np.arange(5, 16 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income']).mean(numeric_only=True)['TotalScore_13'], yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['TotalScore_13'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [108]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='Certainty_3', xlabel='INCOME 18 to 35', yticks = np.arange(0, 6 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income'])['Certainty_3'].mean(), yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['Certainty_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Certainty_3', xlabel='INCOME 36 to 59', yticks = np.arange(0, 6 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income'])['Certainty_3'].mean(), yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['Certainty_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['Certainty_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['Certainty_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['Certainty_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='Certainty_3', xlabel='INCOME 60 to 75', yticks = np.arange(0, 6 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income'])['Certainty_3'].mean(), yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['Certainty_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [109]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='RiskComprehension_3', xlabel='INCOME 18 to 35', yticks = np.arange(0, 3 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income'])['RiskComprehension_3'].mean(), yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['RiskComprehension_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='RiskComprehension_3', xlabel='INCOME 36 to 59', yticks = np.arange(0, 3 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income'])['RiskComprehension_3'].mean(), yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['RiskComprehension_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='RiskComprehension_3', xlabel='INCOME 60 to 75', yticks = np.arange(0, 3 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income'])['RiskComprehension_3'].mean(), yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['RiskComprehension_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [110]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='Numeracy_3', xlabel='INCOME 18 to 35', yticks = np.arange(0, 6 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income'])['Numeracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['Numeracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Numeracy_3', xlabel='INCOME 36 to 59', yticks = np.arange(0, 6 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income'])['Numeracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['Numeracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='Numeracy_3', xlabel='INCOME 60 to 75', yticks = np.arange(0, 6 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income'])['Numeracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['Numeracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [111]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='GraphLiteracy_3', xlabel='INCOME 18 to 35', yticks = np.arange(0, 4 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income'])['GraphLiteracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['GraphLiteracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='GraphLiteracy_3', xlabel='INCOME 36 to 59', yticks = np.arange(0, 4 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income'])['GraphLiteracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['GraphLiteracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='GraphLiteracy_3', xlabel='INCOME 60 to 75', yticks = np.arange(0, 4 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income'])['GraphLiteracy_3'].mean(), yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['GraphLiteracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [112]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==1)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==2)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==2) & (df7['isced']==3)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='Bayesianreasoning_1', xlabel='INCOME 18 to 35', yticks = np.arange(0, 5 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax1.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==2 ].groupby(['income'])['Bayesianreasoning_1'].mean(), yerr = df7.loc[ (df7['age_rec']==2) ].groupby(['income'])['Bayesianreasoning_1'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==1)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==2)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==3) & (df7['isced']==3)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Bayesianreasoning_1', xlabel='INCOME 36 to 59', yticks = np.arange(0, 5 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax2.errorbar(x = [1,2,3,4,5,6], y = df7.loc[ df7['age_rec']==3 ].groupby(['income'])['Bayesianreasoning_1'].mean(), yerr = df7.loc[ (df7['age_rec']==3) ].groupby(['income'])['Bayesianreasoning_1'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
fig, ax3 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==1)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==2)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age_rec']==4) & (df7['isced']==3)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax3, label='ISCED = 3')
ax3.set(ylabel='Bayesianreasoning_1', xlabel='INCOME 60 to 75', yticks = np.arange(0, 5 , 1))
ax3.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
ax3.errorbar(x = df7.loc[ df7['age_rec']== 4 ]['income'].unique(), y = df7.loc[ df7['age_rec']==4 ].groupby(['income'])['Bayesianreasoning_1'].mean(), yerr = df7.loc[ (df7['age_rec']==4) ].groupby(['income'])['Bayesianreasoning_1'].sem(), fmt='o', color = lighten_color('gray',0.5))
plt.show()
In [113]:
# Age weighted mean method
In [114]:
df2["age"].value_counts()
Out[114]:
age 30.5 301 40.5 171 21.5 92 50.5 54 60.5 19 70.5 6 Name: count, dtype: int64
In [115]:
age_m = (30.5 * 301 + 40.5*171 + 21.5*92 + 50.5*54 + 60.5*19+ 70.6*6)/(301+171+92+54+19+6)
age_m
Out[115]:
34.811975116640745
In [ ]:
In [116]:
df7["income"].value_counts()
Out[116]:
income 2 281 1 125 3 121 4 46 5 36 6 34 Name: count, dtype: int64
In [ ]:
In [ ]:
In [117]:
df7.loc[(df7['age'] < age_m)].describe()
Out[117]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 393.000000 | 393.0 | 393.000000 | 393.000000 | 3.930000e+02 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 | 393.000000 |
| mean | 28.393130 | 2.0 | 1.422392 | 2.394402 | 9.461581e+06 | 0.552163 | 1.195929 | 1.165394 | 1.712468 | 0.244275 | 18.405428 | 39.864292 | 38.846480 | 57.082273 | 24.427481 | 4.870229 | 37.463300 |
| std | 3.815754 | 0.0 | 0.548381 | 1.241160 | 4.116973e+07 | 0.737447 | 0.917396 | 0.931656 | 1.028310 | 0.430204 | 24.581570 | 30.579878 | 31.055203 | 34.276987 | 43.020409 | 2.154955 | 16.576576 |
| min | 21.500000 | 2.0 | 1.000000 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 30.500000 | 2.0 | 1.000000 | 2.000000 | 3.000000e+05 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 3.000000 | 23.076923 |
| 50% | 30.500000 | 2.0 | 1.000000 | 2.000000 | 1.000000e+06 | 0.000000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 0.000000 | 33.333333 | 33.333333 | 66.666667 | 0.000000 | 5.000000 | 38.461538 |
| 75% | 30.500000 | 2.0 | 2.000000 | 3.000000 | 5.000000e+06 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 0.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 0.000000 | 7.000000 | 53.846154 |
| max | 30.500000 | 2.0 | 3.000000 | 6.000000 | 5.000000e+08 | 3.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 10.000000 | 76.923077 |
In [118]:
df7.loc[(df7['age'] > age_m)].describe()
Out[118]:
| age | age_rec | isced | income | wealth | Certainty_3 | RiskComprehension_3 | GraphLiteracy_3 | Numeracy_3 | Bayesianreasoning_1 | Certainty_% | RiskComprehension_% | GraphLiteracy_% | Numeracy_% | Bayesianreasoning_% | TotalScore_13 | TotalScore_% | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 2.500000e+02 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.000000 | 250.00000 | 250.000000 | 250.000000 |
| mean | 44.900000 | 3.100000 | 1.376000 | 2.708000 | 1.688600e+07 | 0.664000 | 1.200000 | 1.220000 | 1.740000 | 0.276000 | 22.133333 | 40.000000 | 40.666667 | 58.000000 | 27.60000 | 5.100000 | 39.230769 |
| std | 7.379555 | 0.300602 | 0.569139 | 1.427898 | 6.660925e+07 | 0.780732 | 0.882676 | 0.991733 | 0.990112 | 0.447914 | 26.024394 | 29.422525 | 33.057763 | 33.003725 | 44.79135 | 2.315046 | 17.808046 |
| min | 40.500000 | 3.000000 | 1.000000 | 1.000000 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.000000 | 0.000000 |
| 25% | 40.500000 | 3.000000 | 1.000000 | 2.000000 | 5.000000e+05 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 33.333333 | 0.000000 | 33.333333 | 0.00000 | 3.000000 | 23.076923 |
| 50% | 40.500000 | 3.000000 | 1.000000 | 2.000000 | 2.750000e+06 | 0.500000 | 1.000000 | 1.000000 | 2.000000 | 0.000000 | 16.666667 | 33.333333 | 33.333333 | 66.666667 | 0.00000 | 5.000000 | 38.461538 |
| 75% | 50.500000 | 3.000000 | 2.000000 | 3.000000 | 8.000000e+06 | 1.000000 | 2.000000 | 2.000000 | 3.000000 | 1.000000 | 33.333333 | 66.666667 | 66.666667 | 100.000000 | 100.00000 | 7.000000 | 53.846154 |
| max | 70.500000 | 4.000000 | 3.000000 | 6.000000 | 6.000000e+08 | 3.000000 | 3.000000 | 3.000000 | 3.000000 | 1.000000 | 100.000000 | 100.000000 | 100.000000 | 100.000000 | 100.00000 | 11.000000 | 84.615385 |
In [ ]:
In [119]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.set(ylabel='Total Scores_19', xlabel='INCOME for < median age')
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.set(ylabel='Total Scores_19', xlabel='INCOME for > median age')
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [120]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['TotalScore_13'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['TotalScore_13'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='Total Scores_19', xlabel='INCOME for < median age', yticks = np.arange(5, 16 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['TotalScore_13'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['TotalScore_13'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['TotalScore_13'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='Total Scores_19', xlabel='INCOME for > median age', yticks = np.arange(5, 16 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [121]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['Certainty_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Certainty_3'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Certainty_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='Certainty_3', xlabel='INCOME for < median age', yticks = np.arange(0, 6 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['Certainty_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Certainty_3'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Certainty_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='Certainty_3', xlabel='INCOME for > median age')
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [122]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['RiskComprehension_3'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['RiskComprehension_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='RiskComprehension_3', xlabel='INCOME for < median age', yticks = np.arange(0, 3 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['RiskComprehension_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['RiskComprehension_3'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['RiskComprehension_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='RiskComprehension_3', xlabel='INCOME for > median age', yticks = np.arange(0, 3 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [123]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Numeracy_3'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Numeracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='Numeracy_3', xlabel='INCOME for < median age', yticks = np.arange(0, 6 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['Numeracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Numeracy_3'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Numeracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='Numeracy_3', xlabel='INCOME for > median age', yticks = np.arange(0, 6 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [124]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['GraphLiteracy_3'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['GraphLiteracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='GraphLiteracy_3', xlabel='INCOME for < median age', yticks = np.arange(0, 4 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['GraphLiteracy_3'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['GraphLiteracy_3'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['GraphLiteracy_3'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='GraphLiteracy_3', xlabel='INCOME for > median age', yticks = np.arange(0, 4 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [125]:
fig, ax1 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==1)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==2)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] < age_m) & (df7['isced']==3)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax1, label='ISCED = 3')
ax1.errorbar(x = df7.loc[ (df7['age'] < age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Bayesianreasoning_1'].mean(), yerr = df7.loc[ (df7['age'] < age_m) ].groupby(['income'])['Bayesianreasoning_1'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax1.set(ylabel='Bayesianreasoning_1', xlabel='INCOME for < median age', yticks = np.arange(0, 5 , 1))
ax1.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
fig, ax2 = plt.subplots(figsize=(6, 6))
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==1)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 1')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==2)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 2')
sns.regplot (scatter = False, data = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)].reset_index(drop = True), x = 'income', y = df7.loc[(df7['age'] > age_m) & (df7['isced']==3)]['Bayesianreasoning_1'], fit_reg=True, ci=None, ax=ax2, label='ISCED = 3')
ax2.errorbar(x = df7.loc[ (df7['age'] > age_m) ]["income"].unique(), y = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Bayesianreasoning_1'].mean(), yerr = df7.loc[ (df7['age'] > age_m) ].groupby(['income'])['Bayesianreasoning_1'].sem(), fmt='o', color = lighten_color('gray',0.5))
ax2.set(ylabel='Bayesianreasoning_1', xlabel='INCOME for > median age', yticks = np.arange(0, 5 , 1))
ax2.legend(loc='center left',bbox_to_anchor=(1.0, 0.5))
plt.show()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: